package com.JUC.cha03.sec02;

import java.util.concurrent.TimeUnit;

public class DeamonDemo {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "\t 开始运行，" +
                    (Thread.currentThread().isDaemon()? "守护线程":"用户线程"));
            while (true){

            }
        }, "t1");

        t1.setDaemon(true);
        t1.start();

        // 线程休眠3秒
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println(Thread.currentThread().getName() + "\t ----end 主线程");
    }
}
